from os.path import abspath, dirname, basename, join
import sys

PROJECT_ABSOLUTE_DIR = dirname(abspath(__file__))
PROJECT_NAME = basename(PROJECT_ABSOLUTE_DIR)

LANGUAGE_CODE = 'es'

DEFAULT_CHARSET = 'utf-8'

LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'

SITE_ID = 1

SECRET_KEY = 'td)ql36r9--6(flg3pfe&b1)&hq)scm$s)&^2hdzg#3u-8zn89'

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
)

MIDDLEWARE_CLASSES = (
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.middleware.locale.LocaleMiddleware',
   'django.middleware.common.CommonMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.request',
)

ugettext = lambda s: s

LANGUAGES = (
  ('es', 'Espanol'),
  ('en', 'English'),
)

TEMPLATE_DIRS = (
    join(PROJECT_ABSOLUTE_DIR, "templates"),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'index',
    'staff',
    'inventory',
    'exchanges',
)

sys.path.append(join(PROJECT_ABSOLUTE_DIR, "apps"))

TEMPLATE_DIRS = (
    join(PROJECT_ABSOLUTE_DIR, "templates"),
)
ADMIN_TEMPLATE_DIRS = (
    join(PROJECT_ABSOLUTE_DIR, "templates"),
)

ROOT_URLCONF = 'urls'

try:
    from local_settings import *
except ImportError:
    debug_msg ="Can't find local_settings.py, using default settings."
    try:
        from mod_python import apache
        apache.log_error("%s" % debug_msg, apache.APLOG_NOTICE)
    except ImportError:
        import sys
        sys.stderr.write("%s\n" % debug_msg)
